package simplyrugby.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import simplyrugby.interceptor.TokenInterceptor;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 白名单
        List<String> list = new ArrayList<>();
        list.add("/api/user/login");
        list.add("/api/user/register");
        list.add("/api/role/list");
        list.add("/api/user/exist/*");


        registry.addInterceptor(new TokenInterceptor())
                .excludePathPatterns(list)
                .addPathPatterns("/api/**")
                .order(1);
    }
}
